package com.yohu.device.controller;

import com.baidu.dueros.model.Request;
import com.yohu.device.bot.TaxBot;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

@RestController
@RequestMapping("/tax")
public class TaxController {


    @RequestMapping("/ask")
    public String ask(HttpServletRequest request) throws IOException {
        // 根据request创建Bot
        TaxBot bot = new TaxBot(request);
        // 打开签名验证
        // bot.enableVerify();

        // 线下调试时，可以关闭签名验证
        bot.disableVerify();

        try {
            // 调用bot的run方法
            return bot.run();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "{\"status\":1,\"msg\":\"\"}";
    }
}
